package com.wayhome.srpingbootmybatis.fileimportmanager.controller;

import com.wayhome.srpingbootmybatis.config.ApiResult;
import com.wayhome.srpingbootmybatis.fileimportmanager.dto.ImportFileDTO;
import com.wayhome.srpingbootmybatis.fileimportmanager.dto.ImportFileRlstDTO;
import com.wayhome.srpingbootmybatis.fileimportmanager.dto.QImportRlstDTO;
import com.wayhome.srpingbootmybatis.fileimportmanager.service.FileImportRlstService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping(value = "/web/fileImportManager")
public class FileImportController {

    @Resource
    private FileImportRlstService fileImportRlstService;

    @PostMapping(value = "/downTemplate")
    public void downTemplate(@RequestBody QImportRlstDTO qImportRlstDTO) throws Exception {
        fileImportRlstService.downTemplate(qImportRlstDTO);
    }

    @PostMapping(value = "/importFile")
    public ApiResult importFile(ImportFileDTO importFileDTO) throws Exception {

        return fileImportRlstService.importFile(importFileDTO);
    }

    @PostMapping(value = "/queryImportRlstPage")
    public ApiResult<List<ImportFileRlstDTO>> queryImportRlstPage(@RequestBody QImportRlstDTO qImportRlstDTO) throws Exception {
        return fileImportRlstService.queryImportRlstPage(qImportRlstDTO);
    }

    @PostMapping(value = "/downImportRlstFile")
    public void downImportRlstFile(@RequestBody QImportRlstDTO qImportRlstDTO) throws Exception {
        fileImportRlstService.downImportRlstFile(qImportRlstDTO);
    }
    @PostMapping(value = "/saveAsyncTask")
    public ApiResult saveAsyncTask(@RequestBody QImportRlstDTO qImportRlstDTO) throws Exception {
        return fileImportRlstService.saveAsyncTask(qImportRlstDTO);
    }

}
